<?php

$trackingcode=$_SESSION['trackingcode'];
//echo $trackingcode;
//$table = "";

$conn = mysql_connect('localhost', 'root', '');
if (!$conn) {
    die('Could not connect: ' . mysql_error());
}
//echo 'Connected successfully';

mysql_select_db('tuts_rest', $conn);


  echo '<table id="myTable" class="tablesorter" border="1" cellspacing="1" cellpadding="5">';


  echo '<tr>';

	echo '<th>IDFacebook</th>';
	echo '<th>Nama Audience</th>';
	echo '<th>Gender</th>';

	echo '</tr>';

 
	
	
	
	$sql = 'SELECT * FROM users where idanalytics ="'.$trackingcode.'"';
	$resultquery = mysql_query($sql);
	if($resultquery === FALSE) {
    die(mysql_error()); // TODO: better error handling
	}
	
	


	while($audience = mysql_fetch_array($resultquery)) {
	echo '<tr>';
	echo '<td align="right">'.$audience['idfacebook'].'</td>';
	echo '<td align="right">'.$audience['username'].'</td>';
	echo '<td align="right">'.$audience['gender'].'</td>';
	echo '</tr>';	

		
		
		}
	

	


 echo '</table>';


//print $table;



  



?>

<script type="text/javascript">
$(document).ready(function() 
    { 
        $("#myTable").tablesorter(); 
    } 
); 
    

</script>

